<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>sql执行结果</title>
</head>
<body>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="tabbable">
            <ul class="nav nav-tabs" id="myTab">
                <c:forEach items="${execResults}" var="results" varStatus="vs">
                    <c:set var="classes" value=""/>
                    <c:if test="${vs.index==0}">
                        <c:set var="classes" value="active"/>
                    </c:if>
                    <c:if test="${vs.index != 0 && vs.index%2==0}">
                        <c:set var="classes" value="tab-red"/>
                    </c:if>
                    <li class="${classes}">
                        <a data-toggle="tab" href="#result-${vs.index+1}">
                            结果${vs.index+1}
                        </a>
                    </li>
                </c:forEach>
            </ul>
            <div class="tab-content" style="padding-left: 0px;padding-right: 0px;padding-top: 0px;">
                <c:forEach items="${execResults}" var="results" varStatus="vs">
                    <c:set var="activeClass" value=""/>
                    <c:if test="${vs.index==0}">
                        <c:set var="activeClass" value="active"/>
                    </c:if>
                    <div id="result-${vs.index+1}" class="tab-pane in ${activeClass}">
                        <c:choose>
                            <c:when test="${fn:length(results.heads)>0}">
                                <%--表格结果--%>
                                <div class="col-xs-12 col-md-12" style="float: none;padding-left: 0px;padding-right: 0px;">
                                    <div class="well with-header with-footer" style="padding-left: 0px;padding-right: 0px;padding-top: 40px;padding-bottom:39px;">
                                        <div class="header bordered-success">
                                            总行数：${results.row}
                                        </div>
                                        <div class="table-scrollable">
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                <tr>
                                                    <c:forEach items="${results.heads }" var="head">
                                                        <th scope="col" >${head}</th>
                                                    </c:forEach>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                    <c:forEach items="${results.data}" var="rowData">
                                                        <tr>
                                                            <c:forEach items="${rowData}" var="data">
                                                                <td>${data}</td>
                                                            </c:forEach>
                                                        </tr>
                                                    </c:forEach>
                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="footer">
                                            <code>
                                                sql语句：${results.sql}
                                            </code>
                                        </div>
                                    </div>
                                </div>
                            </c:when>
                            <c:otherwise>
                                <div class="col-xs-12 col-md-12"style="float: none;" >
                                    <p>受影响函数：${results.row}</p>
                                    <p>sql语句：<span class="red">${results.sql}</span></p>
                                    <c:if test='${results.errorMsg != null&&results.errorMsg != ""}'>
                                        <p>错误信息：${results.errorMsg}</p>
                                    </c:if>
                                </div>
                            </c:otherwise>
                        </c:choose>
                    </div>
                </c:forEach>
            </div>
        </div>
    </div>
</div>
</body>
</html>
